package com.zmzncs.lmtc.module.promotion.service.impl;

import com.zmzncs.lmtc.common.util.ExceptionUtil;
import com.zmzncs.lmtc.module.promotion.pojo.duration_rule_park.DurationRulePark;
import com.zmzncs.lmtc.module.promotion.dao.DurationRuleParkMapper;
import com.zmzncs.lmtc.module.promotion.pojo.duration_rule_park.DurationRuleParkDTO;
import com.zmzncs.lmtc.module.promotion.service.DurationRuleParkService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
 * <p>
 * 促销-时长规则类型 服务实现类
 * </p>
 *
 * @author 任建波
 * @since 2020-08-12
 */
@Service
@Slf4j
public class DurationRuleParkServiceImpl extends ServiceImpl<DurationRuleParkMapper, DurationRulePark> implements DurationRuleParkService {

    @Autowired
    DurationRuleParkMapper durationRuleParkMapper;

    /**
     * 根据parkId查询该停车场规则的其他停车场
     */
    @Override
    public List<DurationRuleParkDTO> getDurationRuleParkByParkId(String parkId, String keyword) {
        return durationRuleParkMapper.getDurationRuleParkByParkId(parkId, keyword);
    }

    /**
     * 根据时长规则id停车场
     */
    @Override
    public List<DurationRuleParkDTO> getDurationRuleParkByRuleId(Long durationRuleId, String keyword) {
        List<DurationRuleParkDTO> durationRuleParkList = durationRuleParkMapper.getDurationRuleParkByRuleId(durationRuleId, keyword);
        if(durationRuleParkList.size() == 0){
            ExceptionUtil.businessException("时长规则：" + durationRuleId + "没有配置停车场或停车场数据被删除");
        }
        return durationRuleParkList;
    }


}
